package com.zl.tby.core.base.enums;

import org.noear.wood.utils.StringUtils;

/**
 * 视图管理分类枚举
 * @author changpeng
 * @version 1.0
 * @since 2024/8/14 9:40
 */
public enum TbyEducationViewCategoryEnum {
    WZ("物种", "tby_animal_plant", "ap", "id"),
    XJG("宣教馆", "tby_education_room", "room", "id"),
    SQUARE("教育广场", "tby_education_square", "square", "");
    private String value;
    private String joinTableName;
    private String joinTableNameAlias;
    private String joinColumn;
    TbyEducationViewCategoryEnum(String value, String joinTableName, String joinTableNameAlias, String joinColumn) {
        this.value = value;
        this.joinTableName = joinTableName;
        this.joinTableNameAlias = joinTableNameAlias;
        this.joinColumn = joinColumn;
    }

    public static String getValueByCode(String code) {
        if (StringUtils.isEmpty(code)) {
            return "";
        }
        TbyEducationViewCategoryEnum[] array = values();
        for (TbyEducationViewCategoryEnum e : array) {
            if (e.toString().equals(code)) {
                return e.getValue();
            }
        }
        return "";
    }

    public static TbyEducationViewCategoryEnum getByCode(String code) {
        if (StringUtils.isEmpty(code)) {
            return null;
        }
        TbyEducationViewCategoryEnum[] array = values();
        for (TbyEducationViewCategoryEnum e : array) {
            if (e.toString().equals(code)) {
                return e;
            }
        }
        return null;
    }

    public String getTableName() {
        return this.getJoinTableName() + " " + this.getJoinTableNameAlias();
    }
    public String getColumn() {
        return this.getJoinTableNameAlias() + "." + this.getJoinColumn();
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getJoinTableName() {
        return joinTableName;
    }

    public void setJoinTableName(String joinTableName) {
        this.joinTableName = joinTableName;
    }

    public String getJoinColumn() {
        return joinColumn;
    }

    public void setJoinColumn(String joinColumn) {
        this.joinColumn = joinColumn;
    }

    public String getJoinTableNameAlias() {
        return joinTableNameAlias;
    }

    public void setJoinTableNameAlias(String joinTableNameAlias) {
        this.joinTableNameAlias = joinTableNameAlias;
    }
}
